package vq.codec.ui;

import javax.swing.JOptionPane;

/**
 * Classe criada para representar o frame principal da aplicação.
 *
 * @author Gutemberg Rodrigues
 * @since Outubro de 2009
 * @version 0.3
 */

public class PrincipalScreen extends javax.swing.JFrame {

    public PrincipalScreen() {
        initComponents();
    }

    @SuppressWarnings("unchecked")

    private void initComponents() {

        jMenuItem1 = new javax.swing.JMenuItem();
        painel = new javax.swing.JPanel();
        info1 = new javax.swing.JLabel();
        info2 = new javax.swing.JLabel();
        info4 = new javax.swing.JLabel();
        info3 = new javax.swing.JLabel();
        info5 = new javax.swing.JLabel();
        titleMain = new javax.swing.JLabel();
        titleMain1 = new javax.swing.JLabel();
        menu = new javax.swing.JMenuBar();
        menuOptions = new javax.swing.JMenu();
        SubMenuOptionsInfo = new javax.swing.JMenuItem();
        subMenuOptionsExit = new javax.swing.JMenuItem();
        menuQV = new javax.swing.JMenu();
        subMenuQVCodec = new javax.swing.JMenuItem();
        SubMenuQVDecode = new javax.swing.JMenuItem();
        SubMenuQVOp = new javax.swing.JMenuItem();

        jMenuItem1.setText("jMenuItem1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        painel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Atalhos de Teclado:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(102, 102, 102))); 

        info1.setForeground(new java.awt.Color(153, 153, 153));
        info1.setText("Codificação     -   Alt + C");

        info2.setForeground(new java.awt.Color(153, 153, 153));
        info2.setText("Decodificação  -   Alt + D");

        info4.setForeground(new java.awt.Color(153, 153, 153));
        info4.setText("Sair   -   Alt + S");

        info3.setForeground(new java.awt.Color(153, 153, 153));
        info3.setText("Sobre...             -   Alt + I");

        info5.setForeground(new java.awt.Color(153, 153, 153));
        info5.setText("MSE e PSNR    -   Alt + O");

        javax.swing.GroupLayout painelLayout = new javax.swing.GroupLayout(painel);
        painel.setLayout(painelLayout);
        painelLayout.setHorizontalGroup(
            painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelLayout.createSequentialGroup()
                .addGap(104, 104, 104)
                .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(info2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(info1, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(27, 27, 27)
                .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(painelLayout.createSequentialGroup()
                        .addComponent(info5)
                        .addGap(34, 34, 34)
                        .addComponent(info4))
                    .addComponent(info3))
                .addGap(114, 114, 114))
        );
        painelLayout.setVerticalGroup(
            painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(painelLayout.createSequentialGroup()
                        .addComponent(info1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(info2, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(painelLayout.createSequentialGroup()
                        .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(info5)
                            .addComponent(info4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(info3)))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        titleMain.setFont(new java.awt.Font("MS Reference Sans Serif", 3, 18));
        titleMain.setForeground(new java.awt.Color(204, 204, 204));
        titleMain.setText("Sistema de Codificação e Decodificação");

        titleMain1.setFont(new java.awt.Font("MS Reference Sans Serif", 3, 18));
        titleMain1.setForeground(new java.awt.Color(204, 204, 204));
        titleMain1.setText("Utilizando Quantização Vetorial");

        menuOptions.setText("Opções");

        SubMenuOptionsInfo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.ALT_MASK));
        SubMenuOptionsInfo.setText("Sobre...");
        SubMenuOptionsInfo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SubMenuOptionsInfoActionPerformed(evt);
            }
        });
        menuOptions.add(SubMenuOptionsInfo);

        subMenuOptionsExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
        subMenuOptionsExit.setText("Sair");
        subMenuOptionsExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuOptionsExitActionPerformed(evt);
            }
        });
        menuOptions.add(subMenuOptionsExit);

        menu.add(menuOptions);

        menuQV.setText("Quantização Vetorial");

        subMenuQVCodec.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
        subMenuQVCodec.setText("Codificação");
        subMenuQVCodec.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuQVCodecActionPerformed(evt);
            }
        });
        menuQV.add(subMenuQVCodec);

        SubMenuQVDecode.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.ALT_MASK));
        SubMenuQVDecode.setText("Decodificação");
        SubMenuQVDecode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SubMenuQVDecodeActionPerformed(evt);
            }
        });
        menuQV.add(SubMenuQVDecode);

        SubMenuQVOp.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.ALT_MASK));
        SubMenuQVOp.setText("MSE e PSNR");
        SubMenuQVOp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SubMenuQVOpActionPerformed(evt);
            }
        });
        menuQV.add(SubMenuQVOp);

        menu.add(menuQV);

        setJMenuBar(menu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(93, 93, 93)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(titleMain, javax.swing.GroupLayout.PREFERRED_SIZE, 403, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(39, 39, 39)
                        .addComponent(titleMain1, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE)
                        .addGap(40, 40, 40)))
                .addGap(89, 89, 89))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(painel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(110, 110, 110)
                .addComponent(titleMain)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(titleMain1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
                .addComponent(painel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }

    private void subMenuOptionsExitActionPerformed(java.awt.event.ActionEvent evt) {                                                   

        int resposta = JOptionPane.showConfirmDialog(this,
                        "Deseja realmente sair da aplicação?",
                        "Sair ",
                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);


                if(resposta == JOptionPane.YES_OPTION)
                {
                  System.exit(0);
                }
    }                                                  

    private void SubMenuOptionsInfoActionPerformed(java.awt.event.ActionEvent evt) {                                                   
        ScreenInfo frameScreenInfo = new ScreenInfo();
        frameScreenInfo.openFrameScreenInfo();
    }                                                  

    private void subMenuQVCodecActionPerformed(java.awt.event.ActionEvent evt) {
    	InputScreen frameInputScreen = new InputScreen();
    	frameInputScreen.openFrameInputScreen();
    }                                              

    private void SubMenuQVDecodeActionPerformed(java.awt.event.ActionEvent evt) {
    	ScreenDecode frameScreenDecode = new ScreenDecode();
    	frameScreenDecode.openFrameScreenDecode();
    }                                               

    private void SubMenuQVOpActionPerformed(java.awt.event.ActionEvent evt) {
        InputScreenCalc frameInputScreenCalc = new InputScreenCalc();
        frameInputScreenCalc.openFrameInputScreenCalc();
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {

                PrincipalScreen screen = new PrincipalScreen();
                screen.setLocationRelativeTo(null);
                screen.setVisible(true);
                screen.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);

            }
        });
    }

    private javax.swing.JMenuItem SubMenuOptionsInfo;
    private javax.swing.JMenuItem SubMenuQVDecode;
    private javax.swing.JMenuItem SubMenuQVOp;
    private javax.swing.JLabel info1;
    private javax.swing.JLabel info2;
    private javax.swing.JLabel info3;
    private javax.swing.JLabel info4;
    private javax.swing.JLabel info5;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuBar menu;
    private javax.swing.JMenu menuOptions;
    private javax.swing.JMenu menuQV;
    private javax.swing.JPanel painel;
    private javax.swing.JMenuItem subMenuOptionsExit;
    private javax.swing.JMenuItem subMenuQVCodec;
    private javax.swing.JLabel titleMain;
    private javax.swing.JLabel titleMain1;

}
